const getheight = function() {
	uni.getSystemInfo({
		success: function(res) {
			uni.setStorageSync('statusBarHeight', res.statusBarHeight)
		}
	})
}
// 判断数组
const isArray = Array.isArray || function(obj) {
	return obj instanceof Array;
}
//判断字符是否为空的方法
const isEmpty = function(obj) {
	if (typeof obj == "undefined" || obj == null || obj == "") {
		return true;
	} else {
		return false;
	}
}
const getStrlen = function(str = '') {
	let bytesCount = 0
	for (var i = 0; i < str.length; i++) {
		var c = str.charAt(i);
		//匹配双字节
		if (/^[\u0000-\u00ff]$/.test(c)) {
			bytesCount += 1;
		} else {
			bytesCount += 2;
		}
	}
	return bytesCount
}
const strFormat = function(str) {
	let arr
	let arrItems = ''
	if (isEmpty(str)) return ''
	arr = str.split("\n")
	arr.forEach(v => {
		arrItems += '<p>' + v + '</p>'
	})
	return arrItems
}

export default {
	getheight,
	isArray,
	isEmpty,
	getStrlen,
	strFormat
}
